<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="css/user/public.css">
    <link rel="stylesheet" href="css/user/index.css">
    <script language="javascript" type="text/javascript" src="js/user/jquery-1.8.3.min.js"></script>
    <script language="javascript" type="text/javascript" src="js/user/index.js"></script>
   
    <script charset="utf-8" src="js/user/ajaxfileupload.js"></script>
    <script charset="utf-8" src="js/user/lt-upload-file.js"></script>
    
    <title>修改头像</title>
    <script>
       

    </script>
</head>
<body>
<!--top-->
<div class="contact_main">
    <div class="contact_main_title">
        <p>修改头像</p>
    </div>
    <div class="contact_main_cont">
        <div class="modify_title_box">
         
					 <p><a id="fileHelpBtn" class="a-upload"><input type="file" name="photoFileHelp" id="photoFileHelp" onChange="document.getElementById('subPhotoHelp').click();" style="display:none;" />选择您要上传的头像</a></p>
           <p class="modify_title_box_ts">仅支持JPG、GIF、PNG、JPEG、BMP格式，文件小于4M</p>
           
				   <input type="button" name="subPhotoHelp" id="subPhotoHelp" value="确认上传" style="display:none;"/>
           <div id="imgdiv"><img id="imgShow" src="images/info_list_small_pic.png"/></div>
            
        </div>
        <div class="modify_title_box1">
            <p>推荐头像：</p>
            <div class="modify_title_photo_box">
                <div class="modify_title_photo_box_cont">
                    <ul>

                    </ul>
                </div>
                <div class="cleardiv"></div>
            </div>

        </div>
        <p class="modify_photo_tj"><input type="button" value="提交" id="photo_tj"/></p>
    </div>

</div>
<!--main-->

<script>
	 
        function setDefaultIcon(icon) {
        	
        	$("img#imgShow").attr('src', icon);
        }

    $(document).ready(function(){
        $.ajax({
            url:"lt/user/getDefaultIcons",
            data:"",
            type:"get",
            success:function(data){
               if(data.result != 0){
                    handlerError(data);
                }else{
                    var iconsData = data.defaultIcons;
                    for(var i = 0 ; i<iconsData.length; i++){
//                            alert(shuju[i].accountBalance)
                        var html="<li><img src='"+iconsData[i].icon+"' onclick=\"setDefaultIcon('" + iconsData[i].icon + "')\" ></li>";
                        $(".modify_title_photo_box_cont ul").append(html);
                        var main = $(window.parent.document).find("#iframepage");
                        var thisheight = $(document).height();
                        main.height(thisheight);

                    }
                }
            }

        });
       

        $('#photo_tj').click(function(){
            
            var userId;
            var icon=$("img#imgShow").attr('src');

            $.ajax({
                url:"lt/user/saveIcon",
                data:{userId:userId,icon:icon},
                type:"POST",
                
                dataType:"json",
                success:function(data){
                 if(data.result != 0){
                    handlerError(data);
                }else{
                        //$('.contact_main').submit();
												alert("上传头像成功");
                    }
                }

            });


        });


					
	$(document).ready(function(){
	
		$("#fileHelpBtn").click(function() {
			document.getElementById("photoFileHelp").click();
		});
		$("input#subPhotoHelp").click(function() {
			ajaxFileUpload4Add("/lt/file/upload", "imgShow", "photoFileHelp");
		});
	});

});
</script>
</body>
</html>